package com.livedocumentation.client.web.header;

import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.livedocumentation.client.model.Project;

/**
 * Name and information about the current project being showed in the user
 * manual.
 * 
 * @UserInterface
 */
public class ProjectName extends HorizontalPanel {

	public ProjectName(Project project) {

		this.setSpacing(5);

		this.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

		this.add(getProjectImage(project));

		if (project != null) {

			HTML projectName = new HTML("<font size=3><b>" + project.getName()
					+ "</b></font>");

			this.add(projectName);
		}
	}

	public static Anchor getProjectImage(Project project) {

		Anchor anchorImage = new Anchor();

		anchorImage.setSize("44px", "37px");

		if (project.getImageURL() != null && project.getImageURL().length() > 0) {

			anchorImage.setHTML("<img src='" + project.getImageURL()
					+ "' width='44px' heigth='37px' >");
		}

		return anchorImage;
	}

}